﻿#pragma once
#include <QTimer>
#include "ComponentBase.h"
#include "json_trans.h"
#include "../robot/robot_data.h"

structJ(StatusNotiParam,
	mapping(QString, robNo);
	mapping(int, sysState);
	mapping(QStringList, taskList);
	mapping(QString, errMsg);
	mapping(int, errCode);
	mapping(Joints, joints);
	prop(&robNo, &sysState, &taskList, &errMsg, &errCode, &joints);
);

class TaskScheduler;
class HttpSend;

class StatusNotification  : public ComponentBase
{
	Q_OBJECT

public:
	StatusNotification(QObject* parent);
	~StatusNotification();


	// 组件初始化处理函数
	virtual int ComponentInit() override;
	/*自检接口*/
	virtual bool ComponentCheckSelfState() override;
	/*复位接口*/
	virtual bool ComponentSelfReset() override;
	int SetJointsInfo(const QByteArray& info);

public slots:
	virtual void ResponseSystemState(int event) override;

private slots:
	void OnSendStateToWCS();

private:
	QString m_host;
	StatusNotiParam m_param = {};
	QTimer m_timer{this};
	HttpSend* m_sender = nullptr;
	ComponentBase* m_sh = nullptr;
};
